#include "NmeaParser.h"

#ifdef WIN32
extern "C"
{
    // Handle sentences
    __declspec(dllexport) void Parse(const char *buffer, const int buffSize)
    {
        NmeaParser::GetParser()->Parse(buffer, buffSize);
    }

#ifdef DTWX3DATA_H_

    __declspec(dllexport) int GenerateDTWX3(char* str)
    {
        NmeaParser::GetParser()->GetDTWX3Data().GenerateDTWX3(str);
        return (int)strlen(str);
    }
    // Getting DTW data
    __declspec(dllexport) int GetLeftMotor() 
    {
        return NmeaParser::GetParser()->GetDTWX3Data().GetLeftMotor();
    }
    __declspec(dllexport) int GetRightMotor() 
    {
        return NmeaParser::GetParser()->GetDTWX3Data().GetRightMotor();
    }
    __declspec(dllexport) float GetRearMotor() 
    {
        return NmeaParser::GetParser()->GetDTWX3Data().GetRearMotor();
    }
    __declspec(dllexport) float GetRearServo() 
    {
        return NmeaParser::GetParser()->GetDTWX3Data().GetRearServo();
    }
    // Setting DTW data
    __declspec(dllexport) int SetLeftMotor(int value) 
    {
        return NmeaParser::GetParser()->GetDTWX3Data().SetLeftMotor(value);
    }
    __declspec(dllexport) int SetRightMotor(int value) 
    {
        return NmeaParser::GetParser()->GetDTWX3Data().SetRightMotor(value);
    }
    __declspec(dllexport) int SetRearMotor(float value)
    {
        return NmeaParser::GetParser()->GetDTWX3Data().SetRearMotor(value);
    }
    __declspec(dllexport) int SetRearServo(float value)
    {
        return NmeaParser::GetParser()->GetDTWX3Data().SetRearServo(value);
    }
#endif /* DTWX3DATA_H_ */


#ifdef PCX03DATA_H_
    __declspec(dllexport) int SetJoystickX(float value)
	{
		return NmeaParser::GetParser()->GetPCX03Data().SetJoystickX(value);
	}
	__declspec(dllexport) int SetJoystickY(float value)
	{
		return NmeaParser::GetParser()->GetPCX03Data().SetJoystickY(value);
	}
    __declspec(dllexport) int SetJoystickZ(float value)
	{
		return NmeaParser::GetParser()->GetPCX03Data().SetJoystickZ(value);
	}
    __declspec(dllexport) int SetThrottle(float value)
	{
		return NmeaParser::GetParser()->GetPCX03Data().SetThrottle(value);
	}
	__declspec(dllexport) int GeneratePCX03(char* str)
	{
		int err(0);

		std::string sentence;
		if (err = NmeaParser::GetParser()->GetPCX03Data().GenerateSentence(sentence))
			return err;

		strcpy(str, sentence.c_str());
		
		return sentence.size();
	}

	__declspec(dllexport) int ParsePCX03(char* str)
	{
		return NmeaParser::GetParser()->GetPCX03Data().GenerateSentence(std::string(str));
	}

#endif /* PCX03DATA_H_ */

#ifdef AVX03DATA_H_
    __declspec(dllexport) float GetYaw() 
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetYaw();
    }

    __declspec(dllexport) float GetPitch()
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetPitch();
    }

    __declspec(dllexport) float GetRoll()
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetRoll();
    }

    __declspec(dllexport) float GetReserve1()
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetReserve1();
    }

    __declspec(dllexport) float GetReserve2()
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetReserve2();
    }

    __declspec(dllexport) float GetReserve3()
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetReserve3();
    }

    __declspec(dllexport) float GetReserve4()
    { 
        return NmeaParser::GetParser()->GetAVX03Data().GetReserve4();
    }

	__declspec(dllexport) int GenerateAVX03(char* str)
	{
		int err(0);

		std::string sentence;
		if (err = NmeaParser::GetParser()->GetAVX03Data().GenerateSentence(sentence))
			return err;

		strcpy(str, sentence.c_str());
		
		return 0;
	}

	__declspec(dllexport) int ParseAVX03(char* str)
	{
		return NmeaParser::GetParser()->GetAVX03Data().GenerateSentence(std::string(str));
	}

#endif /* PCX03DATA_H_ */

}
#endif /* WIN_32*/